home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / 80x0393.zip / COPRTEST.C < prev    next >
C/C++ Source or Header  |  1992-09-30  |  1KB  |  43 lines

  1. /*
  2. **  coprtest.c
  3. **  By: Doug Mansell
  4. **  Re: VGA palette changing
  5. **  Link copper.asm with coprtest.c for a little demo...
  6. */
  7.  
  8. #include <math.h>
  9.  
  10. #define SCREENLINES 400             /* suitable for 80x25 text */
  11. #define PALSIZE SCREENLINES+1
  12.  
  13. struct _rgb 
  14. {
  15.   unsigned char red, green, blue;
  16. } cols[PALSIZE];
  17.  
  18. void pascal copper(int lines, unsigned char DACnum,
  19.                    void *colours, int count);
  20.  
  21. void main()
  22. {
  23.   int loop;
  24.   double x, phase;
  25.  
  26.   /* construct a pretty rainbow colour palette */
  27.   phase = 2 * M_PI / 3;
  28.  
  29.   for (loop = 0; loop < PALSIZE; loop++) 
  30.   {
  31.      x = 2 * M_PI * loop / PALSIZE;
  32.      cols[loop].red   = 32 * sin(x) + 31;
  33.      cols[loop].green = 32 * sin(x + phase) + 31;
  34.      cols[loop].blue  = 32 * sin(x + 2*phase) + 31;
  35.   }
  36.  
  37.   /* hold the palette steady for 500 screen refreshes :-) */
  38.   copper(SCREENLINES, 0 ,cols, 500);
  39.   puts("press a key to roll it up the screen"); 
  40.   getch();
  41.   copper(SCREENLINES - 1, 0, cols, 500);
  42.